<?php 
	include './header.php';

	//判断是否登录
	if (empty($_SESSION['user'])) 
	{
		success('你还没有登录',URL.'/login.php',1);
		return false;
	}

	//查询地址表
	$add_model=new Model('address');
	$list=$add_model->select();
	//var_dump($list);
	//var_dump($_SESSION['car']);
	$total=0;
?>
<div class="clear"></div>
<div id="main">
	<div class="goods">
		<table>
			<tr height="40" align="left" style="font-size:22px;">
				<th > &nbsp;收货地址：</th>
			</tr>
			<?php if (!empty($list)) :?>
				<form action="<?php echo URL;?>/doorder.php?a=choose" method="post">
					<?php foreach ($list as $key => $value) :?>
						<tr height="40" align="left">
							<th>
								&nbsp;&nbsp;<input type="radio" name="address" value="<?php echo $value['id'];?>"> 
								&nbsp;<?php echo $value['address'];?> 
								&nbsp;<?php echo $value['receiver'];?> 
								&nbsp;<?php echo $value['tel'];?> 
								&nbsp;<?php echo $value['postcode'];?> 
							</th>
						</tr>
					<?php endforeach;?>
					<tr align="left">
						<th><a href="<?php echo URL;?>/order_address.php"><span style="color:#000;font-size:14px;"> &nbsp;添加新地址</span></a></th>
					</tr>
				<?php else :?>
					<tr>
						<th><a href="<?php echo URL;?>/order_address.php"><span style="font:bold 30px/50px 楷体;color:#000;">添加地址</span></a></th>
					</tr>
			<?php endif;?>
		</table>
	</div>
</div>
<div id="main">
	<div class="goods">
		<table border="0" style="border:1px dotted #ccc;margin-top:50px;min-height:200px;" cellpadding="5" cellspacing="0" width="100%">
			<tr style="height:50px;background:#ccc;">
				<th>序号</th>
				<th>商品名称</th>
				<th>图片</th>
				<th>单价</th>
				<th>数量</th>
				<th>小计</th>
			</tr>
			<?php if (empty($_SESSION['car'])) :?>
				<img src="" alt="">
			<?php else:?>
				<?php foreach ($_SESSION['car'] as $key => $value) :?>
					<tr align="center">
						<td><?php echo $value['gid'];?></td>
						<td><?php echo $value['gname'];?></td>
						<td><img src="<?php echo URL.'/public/uploads/'.substr($value['giname'], 0,4).'/'.substr($value['giname'], 4,2).'/'.substr($value['giname'], 6,2).'/50_'.$value['giname'];?>" alt="美工回家生娃了"/>
						</td>
						<td><font style="color:red;">￥:<?php echo $value['gp'];?></font></td>
						<td><?php echo $value['num'];?></td>
						<td><?php echo $value['num']*$value['gp'];
						$total+=$value['num']*$value['gp']?></td>
					</tr>
				<?php endforeach;?>
			<?php endif;?>
			<tr style="height:60px;">
				<td colspan="5">
				<button style="width:100px;height:40px;background:#C40000;border: none;border-radius: 10px;margin-left:20px;">确认订单</button>
				</td>
				<td align="center">
				<span><font style="color:red;">总计:￥:<?php echo $total;?></font></span>
				</td>
			</tr>
		</table>
	</form>
	</div>
</div>
<?php 
	include PATH.'/footer.php';
?>